<!-- 我的弹窗 -->

<template>
  <WebModal>
    <WebForm>
      <EasyRow flex>
        <div class="flex0">
          <FormPhoto
            bind="coverUrl"
            folder="article"
            text="240 * 200"
            tip="请上传封面"
            :max="2"
            :width="172"
            row3
            noLabel
            required
          />
        </div>

        <div class="flex1">
          <FormInput label="标题" bind="title" required />

          <EasyRow col4>
            <FormSwitch
              label="外部链接"
              bind="isOutUrl"
              trueText="是"
              falseText="否"
              :switchWidth="60"
              :disabled="one.publishStatus === 2"
              @change="one.outUrl = ''"
            />
            <FormLink v-if="one.isOutUrl === 1" label="跳转链接" bind="outUrl" quar3 required />
          </EasyRow>

          <EasyRow col4>
            <FormSelect
              label="发布方式"
              bind="publishType"
              :dict="DICT.TYPE"
              :disabled="one.publishStatus === 2"
              noClear
              @change="one.publishTime = undefinded"
            />
            <FormTime
              v-if="one.publishType === 2"
              label="发布时间"
              bind="publishTime"
              :disabled="one.publishStatus === 2"
              quar3
              required
            />
          </EasyRow>
        </div>
      </EasyRow>

      <FormRichText label="内容" bind="content" folder="article" noLabel required />
    </WebForm>
  </WebModal>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyModal',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb()],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 切换开关
     */
    changeSwitch() {
      const { publishLogistics: app, publishStaff: user } = this.one
      const allFlase = app === 2 && user === 2
      this.one.publishObject = allFlase ? '' : 'ready'
    },

    /**
     * 上传完成
     */
    uploaded(fileName) {
      this.one.fileName = fileName
    },
  },
}
</script>
